﻿@using EntityModel.CommodityMent
@model System.Data.DataTable
@{
    ViewData["Title"] = "添加商品发布";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<body>
    <div class="layuimini-container" style="width:100%;height:100%;position:absolute">
        <div class="layuimini-main">
            <div class="layui-fluid">
                <div class="layui-card">
                    <div class="layui-card-body" style="padding-top: 40px;">
                        <div class="layui-carousel" id="stepForm" lay-filter="stepForm" style="margin: 0 auto;">
                            <div carousel-item>
                                @*选择商品类型 start *@
                                <div>
                                    <form class="layui-form" style="margin: 0 auto;max-width: 460px;padding-top: 40px;">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label required">商品分类</label>
                                            <div class="layui-input-block">
                                                <select name="parentId" lay-filter="aihao" lay-reqtext="请选择商品分类" lay-verify="required">
                                                    @if (Model.Rows.Count == 0)
                                                    {
                                                        <option value=''>请选择</option>
                                                    }
                                                    @foreach (System.Data.DataRow dr in Model.Rows)
                                                    {
                                                        <option value='@dr["parentId"]'>@dr["catName"]</option>
                                                    }

                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <div class="layui-input-block">
                                                <button class="layui-btn" lay-submit lay-filter="formStep">
                                                    &emsp;下一步&emsp;
                                                </button>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                                @*选择商品类型 end *@

                                @*确认商品 start *@
                                <div>
                                    <form class="layui-form" style="margin: 0 auto;max-width: 460px;padding-top: 40px;">
                                        @*<div class="layui-form-item">
                                                <label class="layui-form-label">商品分类</label>
                                                <div class="layui-input-block">
                                                    <select name="parentId" lay-filter="aihao">
                                                        <option value='0'>请选择</option>
                                                    </select>
                                                </div>
                                            </div>*@
                                        <div class="layui-form-item">
                                            <label class="layui-form-label required">二级标题</label>
                                            <div class="layui-input-block">
                                                <input type="text" name="subTitle" lay-verify="stockUser" autocomplete="off" placeholder="请输入二级标题" class="layui-input" required lay-reqtext="二级标题不能为空">
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label required">商品佣金比例</label>
                                            <div class="layui-input-block">
                                                <input type="text" name="commissionRate" lay-verify="number" autocomplete="off" placeholder="请输入佣金比例" class="layui-input" required lay-reqtext="佣金比例不能为空">
                                            </div>
                                        </div>
                                        <div class="layui-form-item layui-form-text">
                                            <label class="layui-form-label">分类SEO标题</label>
                                            <div class="layui-input-block">
                                                <input type="text" name="seoTitle" lay-verify="stockUser" autocomplete="off" placeholder="请输入SEO标题" class="layui-input" required lay-reqtext="SEO标题不能为空">
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label ">分类图片</label>
                                            <div class="layui-upload">
                                                <button type="button" class="layui-btn" id="test1" style="float:left">上传图片</button>
                                                <div class="layui-upload-list">
                                                    <img class="layui-upload-img" id="demo1" style="width:12%;margin-left:5%;">
                                                    <p id="demoText"></p>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="layui-form-item layui-form-text">
                                            <label class="layui-form-label">分类SEO关键字</label>
                                            <div class="layui-input-block">
                                                <input type="text" name="seoKeywords" lay-verify="stockUser" autocomplete="off" placeholder="请输入分类SEO关键字" class="layui-input" required lay-reqtext="SEO关键字不能为空">
                                            </div>
                                        </div>
                                        <div class="layui-form-item layui-form-text">
                                            <label class="layui-form-label">微信端商品列表模板名</label>
                                            <div class="layui-input-block">
                                                <input type="text" name="wechatCatListTheme" lay-verify="stockUser" autocomplete="off" placeholder="请输入微信端商品列表模板名" class="layui-input" required lay-reqtext="微信端商品列表模板名不能为空">
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <div class="layui-input-block">
                                                <button type="button" class="layui-btn layui-btn-primary pre">上一步</button>
                                                <button class="layui-btn" lay-submit lay-filter="formStep2">
                                                    &emsp;确认发布&emsp;
                                                </button>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                                @*确认商品 end *@

                                @*完成添加 start *@
                                <div>
                                    <div style="text-align: center;margin-top: 90px;">
                                        <i class="layui-icon layui-circle"
                                           style="color: white;font-size:30px;font-weight:bold;background: #52C41A;padding: 20px;line-height: 80px;">&#xe605;</i>
                                        <div style="font-size: 24px;color: #333;font-weight: 500;margin-top: 30px;">
                                            商品发布完成
                                        </div>
                                        @*<div style="font-size: 14px;color: #666;margin-top: 20px;">预计两小时到账</div>*@
                                    </div>
                                    <div style="text-align: center;margin-top: 50px;">
                                        <button class="layui-btn next">再次发布</button>
                                        <button class="layui-btn layui-btn-primary">查看所有</button>
                                    </div>
                                </div>
                                @*完成添加 end *@
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        layui.use(['form', 'step', 'upload'], function () {
            var $ = layui.$,
                form = layui.form,
                upload = layui.upload,  //图片上传
                step = layui.step;
            form.render();

            var uploadInst = upload.render({
                elem: '#test1'
                , url: 'https://httpbin.org/post' //改成您自己的上传接口
                , before: function (obj) {
                    //预读本地文件示例，不支持ie8
                    obj.preview(function (index, file, result) {
                        $('#demo1').attr('src', result); //图片链接（base64）
                    });
                }
                , done: function (res) {
                    //如果上传失败
                    if (res.code > 0) {
                        return layer.msg('上传失败', { icon: 2 });
                    }
                    //上传成功
                }
                , error: function () {
                    //演示失败状态，并实现重传
                    var demoText = $('#demoText');
                    demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                    demoText.find('.demo-reload').on('click', function () {
                        uploadInst.upload();
                    });
                }
            });
            step.render({
                elem: '#stepForm',
                filter: 'stepForm',
                width: '100%', //设置容器宽度
                stepWidth: '750px',
                height: '500px',
                stepItems: [{
                    title: '选择商品分类信息'
                }, {
                    title: '确认商品分类发布信息'
                }, {
                    title: '完成'
                }]
            });


            form.on('submit(formStep)', function (data) {
                step.next('#stepForm');
                return false;
            });

            form.on('submit(formStep2)', function (data) {
                step.next('#stepForm');
                return false;
            });

            $('.pre').click(function () {
                step.pre('#stepForm');
            });

            $('.next').click(function () {
                step.next('#stepForm');
            });
        })
    </script>
</body>

